package com.example.test15middleware.util;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @Author: fxy
 * @Date: 2022/07/21/11:16
 * @Description:
 */
public class RabbitMqUtils {
    /**
     * 得到一个连接的 channel
     * @return
     * @throws Exception
     */
    public static Channel getChannel() throws Exception{
        //创建一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("127.0.0.1");
        factory.setUsername("guest");
        factory.setPassword("guest");
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        return channel;
    }
}
